﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _1.SchoolExercise.Model
{
    public class Course
    {
        private Dictionary<int, Student> students;
        public static int MaxStudentsInCourseCount = 30;

        public Course()
        {
            this.students = new Dictionary<int, Student>();
        }

        public IEnumerable<Student> Students
        {
            get 
            { 
                return this.students.Values;
            }
        }

        public void AddStudent(Student student)
        {
            if (!this.students.ContainsKey(student.FacultyNumber))
            {
                if (this.students.Count >= MaxStudentsInCourseCount)
                {
                    throw new Exception(String.Format("Max {0} students in a course.", MaxStudentsInCourseCount));
                }

                this.students[student.FacultyNumber] = student;
            }
        }

        public void RemoveStudent(Student student)
        {
            if (this.students.ContainsKey(student.FacultyNumber))
            {
                this.students.Remove(student.FacultyNumber);
            }
        }
    }
}
